<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.List"%>
<%@page import="cn.company.bean.Module"%>
<%@page import="cn.company.database.DBUtils"%>
<%@page import="cn.company.bean.Sort"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>后台管理—分类管理</title>
<%
	String path = request.getContextPath();
	List<Module> modules = DBUtils.getModules();
	List<Sort> sorts = DBUtils.getSorts();
%>
</head>
<body>
<div id="mainDiv">
		<c:import url="../public/top.jsp" />
		<div id="centerDiv">
			<c:import url="../public/navigation.jsp"></c:import>
			<div id="right"> 
				<div id="current">&nbsp;&nbsp;&nbsp;&nbsp;当前位置: 分类管理</div>
				<div id="form">
					<P>&nbsp;</P>
					<form action="<%=path %>/OurHomeControlServlet" method="post">
						<input type="hidden" name="action" value="addsort" />
						分类名称：<input type="text" name="sortname">
						所属模块：
						<select name="module">
							<%
								for(int i = 0;i < modules.size();i++){
							%>
									<option value="<%=modules.get(i).getId() %>"><%=modules.get(i).getName() %></option>
							<%
								}
							%>
						</select>
						<input type="submit" value="提交内容"></input>
					</form>
					<P>&nbsp;</P>
					<table border="1" cellpadding="0" cellspacing="0" style="border-color:#000000;">
						<tr bgcolor="#e8e8e0">
							<td width="100" align="center">分类名称</td>
							<td width="100" align="center">所属模块</td>
							<td width="50" align="center">删除</td>
							<td width="50" align="center">编辑</td>
						</tr>
						<%
							for(int i = 0;i < sorts.size();i++){
						%>
							<tr>
								<td align="center"><%=sorts.get(i).getSortName() %></td>
								<td align="center"><%=DBUtils.getModuleNameById(sorts.get(i).getModuleId()) %></td>
								<td align="center"><a href="<%=path %>/OurHome/public/delete.jsp?id=<%=sorts.get(i).getId() %>&table=sort&redirect=<%=path %>/OurHome/sort/addsort.jsp">删除</a></td>
								<td align="center"><a href="<%=path %>/OurHome/sort/updateSort.jsp?id=<%=sorts.get(i).getId() %>">修改</a></td>
							</tr>
						<%		
							}
						%>
					</table>
					<p>&nbsp;</p>
				</div>
			</div>
		</div>
		<div id="bottomDiv"></div>
	</div>
	<script language="javascript">
		$("#test1").toggle(function(){$("#test").slideDown();},function(){$("#test").slideUp();});
	</script>
</body>
</html>